package com.puboot.common.util;

import java.math.BigDecimal;
import java.util.List;

/**
 * 陶瓷
 * Created by chen on 2021/12/25.
 */
public class CeramicsUtil {

    /**
     * 温室气体排放总量，单位为t
     * @param eBurn 燃料燃烧二氧化碳排放量，单位为t
     * @param eProcess 过程排放量，单位为t
     * @param ePurchaseElectric 购入热力对应的二氧化碳排放量，单位为t
     * @param ePurchaseHeat 购入热力对应的二氧化碳排放量，单位为t
     * @param eOutputElectric 输出电力对应二氧化碳排放量，单位为t
     * @param eOutputHeat 输出热力对应二氧化碳排放量，单位为t
     * @return
     */
    public static Double getE(Double eBurn, Double eProcess, Double ePurchaseElectric, Double ePurchaseHeat, Double eOutputElectric,
                              Double eOutputHeat) {
        BigDecimal eOutputElectricB = new BigDecimal(eOutputElectric);
        BigDecimal eOutputHeatB = new BigDecimal(eOutputHeat);
        BigDecimal jsgc1 = GasDCUtil.allAdd(eBurn, eProcess, ePurchaseElectric, ePurchaseHeat);
        BigDecimal jsgc2 = jsgc1.subtract(eOutputElectricB);
        BigDecimal jsgc3 = jsgc2.subtract(eOutputHeatB);
        return jsgc3.doubleValue();
    }


    /**
     * 过程排放量，单位为t
     * @param fs 原料消耗量（扣除含水量），单位为t
     * @param others 原料利用率，单位为%
     * @param ccaco3s 使用原料中碳酸钙的质量分数，单位为%
     * @param cmgco3s 使用原料中碳酸镁的质量分数，单位为%
     * @return
     */
    public static Double getEProcess(List<String> fs, List<String> others, List<String> ccaco3s, List<String> cmgco3s){
        BigDecimal result = new BigDecimal(0.0);
        BigDecimal cl1B = new BigDecimal(100);
        BigDecimal cl2B = new BigDecimal(84);
        for (int i = 0; i < fs.size(); i++) {
            BigDecimal jsgc2 = GasDCUtil.allMul(Double.valueOf(ccaco3s.get(i)), 44.0).divide(cl1B, 10, BigDecimal.ROUND_HALF_UP);
            BigDecimal jsgc3 = GasDCUtil.allMul(Double.valueOf(cmgco3s.get(i)), 44.0).divide(cl2B, 10, BigDecimal.ROUND_HALF_UP);
            BigDecimal jsgc4 = jsgc2.add(jsgc3);
            BigDecimal jsgc1 = GasDCUtil.allMul(Double.valueOf(fs.get(i)), Double.valueOf(others.get(i)), jsgc4.doubleValue());
            result = result.add(jsgc1);
        }
        return result.doubleValue();
    }

}
